package com.sys.gradepaysys.service;

import com.sys.gradepaysys.dao.BaseDao;
import com.sys.gradepaysys.entity.Admin;

import java.util.List;

public class AdminServiceImpl implements AdminService{
    @Override
    public Admin login(String username, String password) {
        String sql="select * from admin where username=?";
        String arr[]={username};
        List<Admin> admins = BaseDao.selectAdminList(sql, arr);
        Admin admin=new Admin();
        if (admins.size()>0){
            for (Admin admin1 : admins) {
                admin=admin1;
            }
            if (!admin.getPassword().equals(password)){
                throw new RuntimeException("密码不正确!");
            }
        }else {
            throw new RuntimeException("该用户不存在!");
        }
        return admin;
    }
}
